/*加载当前签到的学生列表*/
function initStudentList(checkinId) {
    $("#studentList > tbody > tr").remove();
    var options = {
        type: 'get',
        url: 'http://localhost/api/finger/checkin/'+checkinId+'/students',
        success:function (result) {
            if (result.code === 0){
                var data = result.data;
                for (let i = 0; i < data.length; i++) {
                    $("#studentList").append(
                        '<tr>' +
                        '<td>'+data[i].id+'</td>' +
                        '<td>'+data[i].name+'</td>' +
                        '<td>'+(data[i].checkinStatus === 0 ? '未签到' : '已签到')+'</td>' +
                        '</tr>'
                    )
                }
            }else{
                layer.msg("学生名单加载错误！")
            }
        },
        error:function (result) {
            console.log(result.msg);
        }
    };
    $.ajax(options);
}

/*添加信息*/
function addMsg(msg) {
    $("#infoTextArea").append(msg + '&#10;');
    var obj = document.getElementById("infoTextArea");
    obj.scrollTop = obj.scrollHeight; // good
}

/*上传指纹图像*/
$("#uploadImage").change(function () {
    //获取用户上传的文件
    let fileObj = this.files[0];
    let fileReader = new FileReader();
    //将文件对象传递给内置对象
    fileReader.readAsDataURL(fileObj);
    fileReader.onload = function () {
        $("#fingerprintImg").attr('src', fileReader.result)
    }
})

/*添加遮罩层*/
function openLoadLayer(msg) {
    loadLayer= layer.msg(msg, {
        icon: 16,
        shade: [0.3, '#393D49'],
        time:'-1'
    });
}